def covered(dict1,dict2):
    for i in dict2.keys():
        if i not in dict1.keys() or dict1[i]<dict2[i]: return False 
    return True 

def solve(s,t):
    from collections import Counter 
    m,n=len(s),len(t)
    if m<n: return ""
    dict_t=Counter(t)
    start,end=-1,m 
    l=0
    while l<=m-n and s[l] not in t:l+=1
    if l>m-n: return ''
    r=l+n-1
    dict_s=Counter(s[l:r+1])
    while r<m:
        while covered(dict_s,dict_t) and l<=r:
            if r-l<end-start:
                end,start=r,l 
            l+=1
            dict_s[s[l-1]]-=1 
        r+=1
        if r>=m:break 
        if s[r] in dict_s: dict_s[s[r]]+=1
        else: dict_s[s[r]]=1
    if start<0: return ''
    else: return s[start:end+1]

print(solve("ADOBECODEBANC",'ABC'),solve('a','a'))
        
